package com.fashiontextile.admin.feign.fallback;

import com.fashiontextile.admin.entity.Dict;
import com.fashiontextile.admin.feign.AdminClient;
import com.fashiontextile.common.entity.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class AdminClientFallbackFactory implements FallbackFactory<AdminClient> {
    @Override
    public AdminClient create(Throwable cause) {
        log.warn("管理接口已降级", cause);
        return new AdminClient() {
            @Override
            public R<Dict> selectDict(Long did) {
                return R.fail("服务器出现问题，获取失败");
            }
        };
    }
}
